﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;

namespace BLL.EarningService
{
    /// <summary>
    /// 普通查询(根据条件模糊查询)
    /// </summary>
    public class NomalQueryEarningRecordTransaction : QueryEarningRecordTransaction
    {
        private T_EarningRecordsObject condition;
        public NomalQueryEarningRecordTransaction(T_EarningRecordsObject _Condition)
        {
            this.condition = _Condition;
        }

        public IList<T_EarningRecordsObject> Query()
        {
            IList<T_EarningRecordsObject> list = new List<T_EarningRecordsObject>();
            base.Execute();
            list = base.ResultList;
            list = list.Where(x => x.Db_EarningDate >= condition.BeginDate && x.Db_EarningDate <= condition.EndDate).ToList();

            if (condition.Db_EarningCategory != 0)
            {
                list = list.Where(x => x.Db_EarningCategory == condition.Db_EarningCategory).ToList();    
            }
            if (condition.Db_EarningObject != 0)
            {
                list = list.Where(x => x.Db_EarningObject == condition.Db_EarningObject).ToList();
            }

            return list;
        }
    }
}
